/**
 * 工具
 * @namespace iTool
 */
import { InterfaceProxy } from 'mider'
import { defaultOptions } from './_options'

/** @lends iTool# */
const interfaceOpt = {
  findPages: {
    name: '分页查找',
    url: '/v1/tool-api/tool/actions/findPages',
    method: 'post',
    data: {
      offset: Number,
      limit: Number
    }
  },
  create: {
    name: '新增',
    url: '/v1/tool-api/tool/actions/create',
    method: 'post',
    data: Object
  },
  updateById: {
    name: '根据 ID 更新',
    url: '/v1/tool-api/tool/actions/updateById',
    method: 'post',
    data: {
      id: String,
      update: Object
    }
  },
  deleteById: {
    name: '根据 ID 删除',
    url: '/v1/tool-api/tool/actions/deleteById',
    method: 'post',
    data: {
      id: String
    }
  },
  updateStatus: {
    name: '更新状态',
    url: '/v1/tool-api/tool/actions/updateStatus',
    method: 'post',
    data: {
      id: String,
      status: Number
    }
  },
  batchUpdateStatus: {
    name: '批量更新状态',
    url: '/v1/tool-api/tool/actions/batchUpdateStatus',
    method: 'post',
    data: {
      query: Object,
      update: {
        status: Number
      }
    }
  },
  updateStatisticsById: {
    name: '更新统计信息',
    url: '/v1/tool-api/tool/actions/updateById',
    method: 'post',
    data: {
      id: String,
      statistics: {
        likeCount: Number,
        clickCount: Number,
        showCount: Number,
        forwardCount: Number,
        collectionCount: Number
      }
    }
  },
  getSiteInfo: {
    baseURL: process.env.utilApi,
    url: '/p/v1/tool-api/tool/actions/getSiteInfo',
    method: 'post',
    data: {
      query: {
        url: String
      }
    }
  }
}

/** @mixes iTool */
const iTool = new InterfaceProxy(interfaceOpt, defaultOptions)
export default iTool
